package com.dev;

import org.apache.curator.RetryPolicy;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.ExponentialBackoffRetry;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

/**
 * @author : fujc-dev@qq.com
 * @motto : talk is cheap, show me the code. salute the future!
 */

public class Curator {

    public static void main(String[] args) throws IOException {
        /************************************************Curator模式**********************************************************/
        RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
        CuratorFramework client = CuratorFrameworkFactory.builder()
                .connectString("")
                /** 会话超时时间 */
                .sessionTimeoutMs(60 * 1000)
                /** 连接超时时间 */
                .connectionTimeoutMs(5000)
                .retryPolicy(retryPolicy)
                .build();
        client.start();

        System.in.read();
    }


    public static  void Fule(){
        try {
            File file=new File("src\\aa.txt");
            //这里需要进行抛出异常处理
            FileInputStream f1=new FileInputStream(file);
            for (int i = 0; i < file.length(); i++) {
                //循环读取字符
                char ch=(char)(f1.read());
                System.out.print(ch+" ");
            }
            System.out.println();//换行操作
            //f1.close();//关闭文件
        } catch (Exception e) {
            // TODO: handle exception
            System.out.println("文件打开失败");
        }
    }
}
